﻿using ET.Monitor.DAL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class InverterModel
    {
        string id = "", st = "", et = "", type = "", unitParentId, unitNameCn, unitMachineId;
        int unitOrderId;
        DataTable dtPointsInfo;
        DateTime sTime, eTime;
        public InverterModel(string eId)
        {
            id = eId;
        }

        public InverterModel(string sid, string sTime, string eTime)
        {
            id = sid;
            st = sTime;
            et = eTime;
        }
        public InverterModel(string sid, string type, string sTime, string eTime)
        {
            id = sid;
            st = sTime;
            et = eTime;
            this.type = type;
        }
        public InverterModel(string unitId, string parentId)
        {
            id = unitId;
            unitParentId = parentId;
        }

        public InverterModel(string unitId, string parentId, string nameCn, string machineId, int orderId, string type)
        {
            id = unitId;
            unitParentId = parentId;
            unitNameCn = nameCn;
            unitMachineId = machineId;
            unitOrderId = orderId;
            this.type = type;
        }

        public InverterModel(DataTable dt, DateTime startTime, DateTime endTime)
        {
            this.dtPointsInfo = dt;
            this.sTime = startTime;
            this.eTime = endTime;
        }
        int num = 0;
        public InverterModel(string orgId, DateTime startTime, DateTime endTime, int count)
        {
            this.id = orgId;
            this.sTime = startTime;
            this.eTime = endTime;
            num = count;
        }

        string[] pointName = null;
        public InverterModel(string id, string[] name)
        {
            this.id = id;
            pointName = name;
        }

        InverterDAL dal = new InverterDAL();

        #region 时间段温度
        ArrayList temps;

        public ArrayList Temps
        {
            get { return dal.GetInverterTemps(id, sTime, eTime, num); }
            set { temps = value; }
        }

        #endregion

        #region 汇流箱
        DataTable dtTextBox;

        public DataTable DtTextBox
        {
            get { return dal.GetTextBox(id); }
            set { dtTextBox = value; }
        }
        #endregion

        #region 根据逆变器编码获取逆变器信息

        private DataTable dtInverterInfo;
        public DataTable DtInverterInfo
        {
            get { return dal.GetInverterInfoById(id); }
            set { dtInverterInfo = value; }
        }
        #endregion

        #region 新增逆变器
        bool addInverter;

        public bool AddInverter
        {
            get { return dal.AddInverterModel(id, unitParentId, unitNameCn, unitMachineId, type); }
            set { addInverter = value; }
        }

        #endregion

        #region 修改逆变器
        bool updateInverter;

        public bool UpdateInverter
        {
            get { return dal.UpdateDistrictModel(id, unitNameCn, unitMachineId, unitOrderId); }
            set { updateInverter = value; }
        }
        #endregion

        #region 获取逆变器序号
        DataTable dtOrder;

        public DataTable DtOrder
        {
            get { return dal.GetInverterOrderId(unitParentId); }
            set { dtOrder = value; }
        }

        #endregion

        #region 删除逆变器
        bool delInverter;

        public bool DelInverter
        {
            get { return dal.DeleteDistrictModelById(id); }
            set { delInverter = value; }
        }
        #endregion

        #region 实时负荷
        object power;

        public object Power
        {
            get { return dal.GetInverternPower(id); }
            set { power = value; }
        }
        #endregion

        #region 实时电量
        object realDL;

        public object RealDL
        {
            get { return dal.GetInverterRealDl(id); }
            set { realDL = value; }
        }
        #endregion

        #region 区域实时负荷集合
        object[] powers;

        public object[] Powers
        {
            get { return dal.GetInverternPowers(id); }
            set { powers = value; }
        }
        #endregion

        #region 区域实时电量集合
        object[] realDLs;

        public object[] RealDLs
        {
            get { return dal.GetInverterRealDls(id); }
            set { realDLs = value; }
        }
        #endregion

        #region 逆变器测点集合
        DataTable points;

        public DataTable Points
        {
            get { return dal.GetinverterPoints(id); }
            set { points = value; }
        }
        #endregion

        #region 频率
        object fre;

        public object Fre
        {
            get { return dal.GetInverternFre(id); }
            set { fre = value; }
        }
        #endregion

        #region 温度
        object temp;

        public object Temp
        {
            get { return dal.GetInverternTemp(id); }
            set { temp = value; }
        }
        #endregion

        #region A相电流
        object iacr;

        public object Iacr
        {
            get { return dal.GetInverternIacr(id); }
            set { iacr = value; }
        }
        #endregion

        #region B相电流
        object iacs;

        public object Iacs
        {
            get { return dal.GetInverternIacs(id); }
            set { iacs = value; }
        }
        #endregion

        #region C相电流
        object iac;

        public object Iac
        {
            get { return dal.GetInverternIac(id); }
            set { iac = value; }
        }
        #endregion

        #region A相电压
        object vacr;

        public object Vacr
        {
            get { return dal.GetInverternVacr(id); }
            set { vacr = value; }
        }
        #endregion

        #region B相电压
        object vacs;

        public object Vacs
        {
            get { return dal.GetInverternVacs(id); }
            set { vacs = value; }
        }
        #endregion

        #region C相电压
        object vact;

        public object Vact
        {
            get { return dal.GetInverternVact(id); }
            set { vact = value; }
        }
        #endregion

        #region A相功率
        object pacr;

        public object Pacr
        {
            get { return dal.GetInverternPacr(id); }
            set { pacr = value; }
        }
        #endregion

        #region B相功率
        object pacs;

        public object Pacs
        {
            get { return dal.GetInverternPacs(id); }
            set { pacs = value; }
        }
        #endregion

        #region C相功率
        object pact;

        public object Pact
        {
            get { return dal.GetInverternPact(id); }
            set { pact = value; }
        }
        #endregion

        #region 日发电量
        object elecd;

        public object Elecd
        {
            get { return dal.GetInverternElecd(id); }
            set { elecd = value; }
        }
        #endregion

        #region 累计发电量
        double elect;

        public double Elect
        {
            get { return dal.GetInverternElect(id, st, et); }
            set { elect = value; }
        }
        #endregion

        #region 累计发电小时
        object hour;

        public object Hour
        {
            get { return dal.GetInverternHour(id); }
            set { hour = value; }
        }
        #endregion

        #region 1路输入电压
        object vpv1;

        public object Vpv1
        {
            get { return dal.GetInverternVpv1(id); }
            set { vpv1 = value; }
        }
        #endregion

        #region 2路输入电压
        object vpv2;

        public object Vpv2
        {
            get { return dal.GetInverternVpv2(id); }
            set { vpv2 = value; }
        }
        #endregion

        #region 1路输入电流
        object ipv1;

        public object Ipv1
        {
            get { return dal.GetInverternIpv1(id); }
            set { ipv1 = value; }
        }
        #endregion

        #region 2路输入电流
        object ipv2;

        public object Ipv2
        {
            get { return dal.GetInverternIpv2(id); }
            set { ipv2 = value; }
        }
        #endregion

        #region 累计电量(所有逆变器)
        DataTable dtSumDl;

        public DataTable DtSumDl
        {
            get { return dal.GetSunDl(id, st, et); }
            set { dtSumDl = value; }
        }
        #endregion

        #region 平均功率
        DataTable dtAvgPower;

        public DataTable DtAvgPower
        {
            get { return dal.GetAvgPower(id, st, et); }
            set { dtAvgPower = value; }
        }
        double inverterAvgPower;

        public double InverterAvgPower
        {
            get { return dal.GetInverterAvgPower(id, st, et); }
            set { inverterAvgPower = value; }
        }
        #endregion

        #region 平均发电效率
        DataTable dtAvgEfficiency;

        public DataTable DtAvgEfficiency
        {
            get { return dal.GetAvgEfficiency(id, st, et); }
            set { dtAvgEfficiency = value; }
        }

        double interverAvgEfficiency;

        public double InterverAvgEfficiency
        {
            get { return dal.GetInverterAvgEfficiency(id, st, et); }
            set { interverAvgEfficiency = value; }
        }
        #endregion

        #region 容量
        double rl;

        public double Rl
        {
            get { return dal.GetRL(id); }
            set { rl = value; }
        }
        #endregion

        #region 累计发电效率
        double sumEfficiency;

        public double SumEfficiency
        {
            get { return dal.GetSumEfficiency(id, st, et); }
            set { sumEfficiency = value; }
        }
        #endregion

        #region 累计辐照度
        double sumIrradiance;

        public double SumIrradiance
        {
            get { return dal.GetSumIrradiance(id, st, et); }
            set { sumIrradiance = value; }
        }
        #endregion

        #region 日发电效率
        object dayEfficiency;

        public object DayEfficiency
        {
            get { return dal.GetDayEfficiency(id, et); }
            set { dayEfficiency = value; }
        }
        #endregion

        #region 月发电效率
        object monthEfficiency;

        public object MonthEfficiency
        {
            get { return dal.GetMonthEfficiency(id, et); }
            set { monthEfficiency = value; }
        }
        #endregion

        #region 年发电效率
        double yearEfficiency;

        public double YearEfficiency
        {
            get { return dal.GetYearEfficiency(id, et); }
            set { yearEfficiency = value; }
        }
        #endregion

        #region 大类故障次数
        DataTable dtFaultRecordCount;

        public DataTable DtFaultRecordCount
        {
            get { return dal.GetFaultRecordCount(id, Convert.ToDateTime(st), Convert.ToDateTime(et)); }
            set { dtFaultRecordCount = value; }
        }
        #endregion

        #region 负荷趋势
        double[] powerLine;

        public double[] PowerLine
        {
            get { return dal.GetPowerInverterLine(id, sTime, eTime, num); }
            set { powerLine = value; }
        }
        double[] dcPowerLine;

        public double[] DcPowerLine
        {
            get { return dal.GetDCPowerInverterLine(id, sTime, eTime, num); }
            set { dcPowerLine = value; }
        }
        double[] acPowerLine;

        public double[] AcPowerLine
        {
            get { return dal.GetACPowerInverterLine(id, sTime, eTime, num); }
            set { acPowerLine = value; }
        }

        double[][] powerLines;

        public double[][] PowerLines
        {
            get { return dal.GetPowerLine(id, sTime, eTime, num); }
            set { dispersionRatio = value; }
        }

        #endregion

        #region 电站趋势 离散率
        double[][] dispersionRatio;

        public double[][] DispersionRatio
        {
            get { return dal.GetDispersionRatioLine(id, sTime, eTime, num); }
            set { dispersionRatio = value; }
        }
        #endregion

        #region 实时效率
        object objRealEfficiency;

        public object ObjRealEfficiency
        {
            get
            {
                return dal.GetRealEfficiency(id);
            }

            set
            {
                objRealEfficiency = value;
            }
        }
        #endregion


        #region 逆变器显示信息
        ArrayList listInverter;

        public ArrayList ListInverter
        {
            get
            {
                return dal.GetInverterPointInfo(id);
            }

            set
            {
                listInverter = value;
            }
        }
        #endregion

        #region 故障状态
        double faultState;

        public double FaultState
        {
            get
            {
                return dal.GetFaultState(id);
            }

            set
            {
                faultState = value;
            }
        }


        public double[] FaultStateArray
        {
            get { return dal.GetFaultStateArray(id); }
        }

        public List<double[]> FaultPowerArray
        {
            get { return dal.GetFaultPowerArray(id); }
        }

        #endregion

        #region 获取实施测电集合数据
        List<double[]> list;

        public List<double[]> List
        {
            get
            {
                return dal.GetRealVal(id, pointName);
            }

            set
            {
                list = value;
            }
        }
        #endregion

        #region 额定功率
        DataTable dtRatedRL;

        public DataTable DtRatedRL
        {
            get
            {
                return dal.GetInverterRatedRL(id);
            }

            set
            {
                dtRatedRL = value;
            }
        }
        //获取单个逆变器额定功率
        public object ObjRl
        {
            get
            {
                return dal.GetRatedRL(id);
            }

            set
            {
                objRl = value;
            }
        }

        object objRl;

        #endregion

        #region 电站编码
        object stationId;
        public object StationId
        {
            get
            {
                return dal.GetStationID(id);
            }

            set
            {
                stationId = value;
            }
        }
        #endregion
    }
}
